package com.lotusfall.mysport;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

import com.lotusfall.mysport.controller.UserController;

import org.w3c.dom.Text;

public class regActivity extends AppCompatActivity {
    UserController userController = new UserController();
    TextView username;
    TextView password;
    TextView confirm;
    Button reg;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_reg);

        username = (TextView) findViewById(R.id.text_regName);
        password = (TextView) findViewById(R.id.text_regPassword);
        confirm = (TextView) findViewById(R.id.text_confirmPassword);
        reg = (Button) findViewById(R.id.btn_reg);

        reg.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if(password.getText().toString().equals(confirm.getText().toString())){
                    userController.reg(getApplicationContext(),username.getText().toString(),password.getText().toString());
                    if(userController.regular == 1){
                        Intent intent = new Intent(regActivity.this, regActivity.class);
                        startActivity(intent);
                        finish();
                    }
                }else{
                    Toast.makeText(regActivity.this, "输入密码不一致请重新输入！", Toast.LENGTH_SHORT).show();
                }
            }
        });


    }
}